﻿
CREATE FUNCTION [dbo].[GetContParinte]
(
	-- Add the parameters for the function here
	@sintetic decimal(6,0),
	@analitic1 decimal(6,0),
	@analitic2 decimal(6,0),
	@analitic3 decimal(6,0),
	@analitic4 decimal(6,0),
	@analitic5 decimal(6,0)
	
)
RETURNS varchar(50)
AS
BEGIN
	-- Declare the return variable here
	DECLARE @ResultVar varchar(50)
	SET @ResultVar = 'N/A'
	-- Add the T-SQL statements to compute the return value here
	--SELECT <@ResultVar, sysname, @Result> = <@Param1, sysname, @p1>
	if @analitic1<>0
	begin
		set @ResultVar = LTRIM(RTRIM(cast(@sintetic as varchar(6))))	
		if @analitic2<>0
		begin
			set @ResultVar = @ResultVar +'.'+ LTRIM(RTRIM(cast(@analitic1 as varchar(6))))
			if @analitic3<>0
			begin
				set @ResultVar = @ResultVar +'.'+ LTRIM(RTRIM(cast(@analitic2 as varchar(6))))
				if @analitic4<>0
				begin
					set @ResultVar = @ResultVar +'.'+ LTRIM(RTRIM(cast(@analitic3 as varchar(6))))	
					if @analitic5<>0
						set @ResultVar = @ResultVar +'.' +LTRIM(RTRIM(cast(@analitic4 as varchar(6))))
				end
			end
		end
	end	
	-- Return the result of the function
	RETURN @ResultVar

END